package com.geek.gkpush.util.excp;

/**
 * <h1>异常编码。</h1><br/>
 *
 * <h1><br/><a href="https://u.geekbang.org/subject/arch3/100614201">Java 业务架构实战营：https://u.geekbang.org/subject/arch3/100614201</a></h1><br/><h1><a href="https://gitee.com/ylimhhmily/BizArchPracticeCamp">Java 业务架构实战营代码地址：https://gitee.com/ylimhhmily/BizArchPracticeCamp</a></h1><br/><h1><a href="https://u.geekbang.org/subject/java4th/1001148?source=app_share">高级 Java 工程体系课 2023 版：https://u.geekbang.org/subject/java4th/1001148?source=app_share</a></h1><br/><h1><a href="https://time.geekbang.org/column/intro/100312101?tab=catalog">Dubbo 源码剖析与实战：https://time.geekbang.org/column/intro/100312101?tab=catalog</a></h1>
 *
 * @author hmilyylimh
 * ^_^
 * @version 0.0.1
 * ^_^
 * @date 2022-02-18
 */
public enum GkPushCodeEnum {

    /** <h2>"000000", "成功"</h2> */
    SUCCESS("000000", "成功"),

    /** <h2>"814001", "参数异常"</h2> */
    ARGS_ERROR("814001", "参数异常"),
    /** <h2>"814002", "插入数据异常"</h2> */
    INSERT_DATA_ERROR("814002", "插入数据异常"),
    /** <h2>"814003", "抢单失败"</h2> */
    SNATCH_ORDER_FAILED("814003", "抢单失败"),
    /** <h2>"814004", "获取序列号失败"</h2> */
    GET_SEQUENCE_FAILED("814004", "获取序列号失败"),
    /** <h2>"814005", "插入数据库异常"</h2> */
    INSERT_DB_EXCEPTION("814005", "插入数据库异常"),

    /////////////////////////////////////

    /** <h2>"814994", "编译脚本异常"</h2> */
    COMPILE_SCRIPT_EXCEPTION("814994", "编译脚本异常"),
    /** <h2>"814995", "实例化Bean异常"</h2> */
    INITIALIZING_BEAN_EXCEPTION("814995", "实例化Bean异常"),
    /** <h2>"814996", "Redis的Lua脚本异常"</h2> */
    REDIS_LUA_EXCEPTION("814996", "Redis的Lua脚本异常"),
    /** <h2>"814997", "系统不支持"</h2> */
    UN_SUPPORT_EXCEPTION("814997", "系统不支持"),
    /** <h2>"814998", "限流异常"</h2> */
    LIMIT_EXCEPTION("814998", "限流异常"),
    /** <h2>"814999", "系统异常"</h2> */
    SYSTEM_EXCEPTION("814999", "系统异常"),

    ;

    private final String code;
    private final String msg;

    GkPushCodeEnum(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    /**
     * <h2>是否是成功状态码。</h2>
     *
     * @param: code
     * @return: <h2>{@code true}：是成功状态码；{@code false}：不是成功状态码；</h2>
     */
    public static boolean isSucc(String code) {
        return SUCCESS.getCode().equals(code);
    }
}